package com.apes.scm.masterdata.frame.repository;

import com.apes.framework.jpa.repository.CustomRepository;
import com.apes.scm.masterdata.frame.model.Contacts;
import com.apes.scm.masterdata.party.model.PartyRole;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface ContactsRepository extends CustomRepository<Contacts, String> {

    @Modifying
    @Query(value = "delete from mas_contacts T where T.store_id = :storeId and T.contact_id = :contactId",nativeQuery = true)
    void deleteContactsById (@Param("storeId") String storeId, @Param("contactId") String contactId);

    List<Contacts> findByStoreId(String storeId);

    List<Contacts> findAllByStoreIdAndContactIn(String storeId, List<PartyRole> partyRoleList);

}
